﻿using System;
using System.Diagnostics.Contracts;

namespace Cloak.Mvvm.Navigation
{
	/// <summary>
	/// Associates a page with a view model
	/// </summary>
	[AttributeUsage(AttributeTargets.Class)]
	public sealed class ViewModelAttribute : Attribute
	{
		/// <summary>
		/// Initializes an instance of <see cref="ViewModelAttribute"/>
		/// </summary>
		/// <param name="type">The type of view model associated with the page</param>
		public ViewModelAttribute(Type type)
		{
			Contract.Requires(type != null);

			Type = type;
		}

		/// <summary>
		/// Initializes an instance of <see cref="ViewModelAttribute"/>
		/// </summary>
		/// <param name="type">The type of view model associated with the page</param>
		/// <param name="name">The name of the view model associated with the page</param>
		public ViewModelAttribute(Type type, string name) : this(type)
		{
			Contract.Requires(name != null);

			Name = name;
		}

		/// <summary>
		/// Gets the type of view model associated with the page
		/// </summary>
		public Type Type { get; private set; }

		/// <summary>
		/// Gets the name, if any, of the view model associated with the page
		/// </summary>
		public string Name { get; private set; }
	}
}